<template>
	<view class="content">
		<view class="textarea-box">
			<uv-textarea 
			v-model="content"  
			placeholder="请输入内容"  
			:count="true"  
			maxlength="10000"
			height="calc(100vh - 500rpx)"
			  ></uv-textarea>
		</view>
		
		<view class="btn-box">
			<uv-button type="success" text="复制"  @click="copy()"  ></uv-button>
			<uv-button type="error" text="清空"  @click="clear()"  ></uv-button>
			<uv-button type="primary" text="保存"  @click="save()"  ></uv-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: '',
				guid:''
			}
		},
		onLoad(option) {
			this.guid=option.guid
			this.content = uni.getStorageSync(this.guid)
		},
		onUnload() {
			console.log('onUnload')
			uni.setStorageSync(this.guid,this.content)
		},
		methods: {
			copy(){
				uni.setClipboardData({
					data: this.content,
					success: function () {
						uni.showToast({
							title:"复制成功"
						})
					}
				});
			},
			clear(){
				this.content=""
			},
			save(){
				uni.setStorageSync(this.guid,this.content)
			}
		}
	}
</script>

<style lang="scss"  >
	page{
		background: #f8f8f8;
	}
	
	.content {
		position: relative;
		.textarea-box{
			margin: 30rpx;
		}
		.btn-box{
			margin: 30rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
		}
		
	}
</style>
